#ifndef MYWDIGELAYOUT_H
#define MYWDIGELAYOUT_H


#include <QMap>
#include <QPushButton>
#include <QLabel>
#include <QComboBox>
#include <QStandardItemModel>
#include <QTableView>
#include <QScrollArea>
#include "widget.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QSettings>

const QString LIST_INSERT_STRING = "2386202408645";
const QString LIST_CHECK_STRING  = "2386202418640";


typedef enum {
    EMU_USER_NAME,  //
    EMU_FINISH_TIME,       // 完成时间
    EMU_CUSTOMS_DECLARTION_OUT, // 报关单-出口
    EMU_CUSTOMS_DECLARTION_IN, // 报关单-进口
    EMU_CHECK_LIST_1, // 清单-进口
    EMU_CHECK_LIST_2, // 清单-进口
    EMU_CONTEXT_LINE_EDIT_MAX
} LINE_EDIT_EMU;

typedef enum {
    EMU_SELECT_FILE,  //
    EMU_ADD_DATA,       //
    EMU_DEL_DATA, //
    EMU_GENERATE_FILE, //
    EMU_BUTTON_MAX, //
} BUTTON_FUN_EMU;

typedef enum {
    EMU_USER_LIST_SLIPS = 10,  // 客户清单
    EMU_LIST_SLIPS,       // 清单
    EMU_VERIFICATION_SLIPS, // 核放单
    EMU_CUSTOMS_DECLARTION, // 报关单
    EMU_CHECK_LIST_SLIPS, //核对的清单
    EMU_CHECK_CUSTOMS_DECLARTION, //核对的报关单
    EMU_EMU_INSERT_OPERATOR_USR, //录入人员
    EMU_EMU_CHECK_OPERATOR_USR, //核对人员
    EMU_CONTEXT_MAX
} ContexEnum;

class MyWdigeLayout : public QObject
{
public:
    MyWdigeLayout(Widget *parent);
    void InitLayout();
    bool InitLoadFile();


    QMap<uint32_t, QPushButton*> mButtonMap;
    QMap<uint32_t, QLabel*> mLabelMap;
   // QMap<uint32_t, QComboBox*> mComboBoxMap;
   // QMap<uint32_t, QComboBox*> mComboBoxCheckMap;
    QMap<uint32_t, QLineEdit*> mLineEditMap;
    QMap<uint32_t, QLineEdit*> mLineEditListContentMap; //录入的单量
    QMap<uint32_t, QLineEdit*> mLineEditCheckContentMap; //核对的单量

    QStringList mUserList { "  ", "郑奇", "朱志清", "张冬梅","徐振东"};
    QStandardItemModel *mTableModel;
    QTableView *mTableView;
    QLineEdit *mXlsxFilePath;
    QString mFileName = "";
    QComboBox *mInsertUsrComb;
    QComboBox *mCheckUsrComb;

    QVector<QString>mExcelLineContext = {"客户", "日期", "报关单号-出口",
                                          "报关单号-进口", "客户清单/录入", "清单/录入",
                                          "核放单/录入", "报关单/录入", "录入人员",
                                          "   ", "清单/核对","报关单/核对",
                                          "核对人员", "   ", "核注清单1",
                                          "核注清单2"};


private:
    Widget *mPWidge;
    Ui::Widget *mUi;

    QString mFormPrefixInsert = LIST_INSERT_STRING;
    QString mFormPrefixCheck = LIST_CHECK_STRING;

    void InitFirstLayout(QVBoxLayout *layout);

    void InitSecondLayout(QVBoxLayout *layout);

    void InitThirdLayout(QVBoxLayout *layout);

    void InitForthLayout(QVBoxLayout *layout);

    void InitFifthLayout(QVBoxLayout *layout);

    void InitTableView(QVBoxLayout *layout);

    void SetFilePath();
    void onAddButtonClicked();
    void onDelButtonClicked();
    void ReGenExeclFile();
    void saveToFile(const QString& fileName);
    void InitButtonFun();
    void InitExcelFile();
    bool CheckFileAccessible();
    bool CheckInsertData();
    bool CheckSetting(QSettings &settings);
    bool LoadXlsxFile(QString fileName);
};

#endif // MYWDIGELAYOUT_H
